/**
 * =================================================================
 * 版权所有 2011-2013 深圳市泰海网络科技服务有限公司，并保留所有权利
 * -----------------------------------------------------------------
 * 这不是一个自由软件！您不能在任何未经允许的前提下对程序代码进行修改和使用；
 * 不允许对程序代码以任何形式任何目的的再发布
 * =================================================================
 */
package com.imoney.payment.account.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.imoney.framework.base.entity.Response;
import com.imoney.framework.base.exception.ServiceException;
import com.imoney.payment.account.domain.AccountWater;
import com.imoney.payment.account.domain.TransferRequest;
import com.imoney.payment.account.domain.TransferResponse;
import com.imoney.payment.account.handler.AccountValidHandler;
import com.imoney.payment.account.handler.AccountRepeatHandler;
import com.imoney.payment.account.handler.TransferHandler;
import com.imoney.payment.account.handler.AccountParamHandler;
import com.imoney.payment.account.service.ITransferService;
import com.imoney.payment.chain.HandlerChain;

/**
 * 类说明：<br>
 * 
 * <p>
 * 详细描述：<br>
 * 
 * </p>
 * 
 * <pre>
 * ——————————————————————————————————————————————————————————————————
 * |		修改人		|		修改时间			|		修改原因
 * ——————————————————————————————————————————————————————————————————
 * |	zengxx 曾宪新	|		2013-7-14		|	
 * ——————————————————————————————————————————————————————————————————
 * </pre>
 * 
 * @author zengxx 曾宪新(Xavier.zeng)
 * 
 *         CreateDate: 2013-7-14
 */
@Service
public class TransferServiceImpl implements ITransferService {

	@Resource
	private AccountValidHandler accountValidHandler;

	@Resource
	private AccountRepeatHandler accountRepeatHandler;

	@Resource
	private TransferHandler transferHandler;

	@Resource
	private AccountParamHandler accountParamHandler;

	@Override
	public TransferResponse transfer(TransferRequest request)
			throws ServiceException {

		/** 业务处理返回结果 */
		Response<List<AccountWater>> response = new Response<List<AccountWater>>();

		/** 业务处理链 */
		HandlerChain<List<AccountWater>> chain = new HandlerChain<List<AccountWater>>();
		chain.addHandler(accountParamHandler) // 转账入参验证
				.addHandler(accountValidHandler) // 账户有关效性验证
				.addHandler(accountRepeatHandler) // 转账并发处理
				.addHandler(transferHandler); // 执行转账

		chain.doHandler(chain, request, response);

		return null;
	}

	@Override
	public TransferResponse transfer(List<TransferRequest> request)
			throws ServiceException {

		return null;
	}

}
